/*!
 * \file jbossejb_cpmm.c
 *
 * \brief jboss ejb各种数组解析
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 2.0
 * \author wuwk
 * \date 2016/02/25
 *
 */
#include <stdlib.h>
#include <stdio.h>


#include "jbossejb_core.h"
#include "config.h"


FR_STATIC char * __get_string_reverse(Frbyte_Packet *p_st_data, int i_len)
{
    char *p_boolean = NULL;
    char *p_reverse = NULL;
    int i = 0;

    if (p_st_data == NULL || i_len == 0)
        return NULL;

    p_boolean = (char *)frmalloc(i_len + 1);
    if (p_boolean == NULL)
        return NULL;

    if (bytebuff_get_bytes(p_st_data, p_boolean, i_len) == FR_FAIL)
        goto err;
    p_boolean[i_len] = '\0';

    p_reverse = (char *)frmalloc(i_len + 1);
    if (p_reverse == NULL)
        goto err;
    memset(p_reverse, 0x00, i_len + 1);

    for (; i < i_len; i++)
        p_reverse[i] = p_boolean[i_len - 1 - i];

    frfree(p_boolean);

    return p_reverse;

err:
    if (p_boolean)
        frfree(p_boolean);

    if (p_reverse)
        frfree(p_reverse);

    return NULL;
}

FR_STATIC int __hex_to_boolean(char *p_data
                                 , char *p_json
                                 , char *pi_left_size)
{
    char arr_tmp[2];
    int i_boolean = 0;
    int i_hex = 0;
    int i = 0;

    if (p_st_body_data == NULL || p_key == NULL || p_data == NULL
        || p_json == NULL || pi_left_size == NULL || *pi_left_size == 0)
        return FR_FAIL;

    memset(arr_tmp, 0x00, sizeof(arr_tmp));
    strcpy(arr_tmp, p_data, 1);

    i_hex = atoi(arr_tmp);
    for (i = 0; i < 8; i++)
    {
        i_boolean = i_hex % 2;
        i_hex /= 2;

        snprintf(p_json, *pi_left_size, "%d,", i_boolean);
        *pi_left_size -= 2;
    }

    return FR_SUCC;
}

/*!
 * char数组上报
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_key           (char          上报key)
 * \param *p_data           (char          char数据)
 * \param i_count       (int      个数)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *
 */
FR_STATIC int __jbossejb_char_array_report(Frreport_body_data *p_st_body_data
                               , char *p_key
                               , char *p_data
                               , int i_count)
{
    char *p_json = NULL;
    int i_buff_size = NULL;
    int i_used_size = 0;
    int i = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || p_key == NULL)
        return FR_FAIL;

    i_buff_size = 5 * i_count + 1;
    p_json = (char *)frmalloc(i_buff_size);
    if (p_json == NULL)
        return FR_FAIL;
    memset(p_json, 0x00, i_buff_size);

    strcpy(p_json, "[");
    i_used_size = 1;

    for (; i < i_count; i++)
    {
        if (i == i_count - 1)
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "'%c'", *(p_data+i));
            i_used_size += 3;
        }
        else
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "'%c',", *(p_data+i));
            i_used_size += 4;
        }
    }
    snprintf(p_json+i_used_size, i_buff_size - i_used_size, "]");

    // json格式上报
    if (frreport_body_l7_add_str(p_st_body_data, p_key, p_json) == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * short数组上报
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_key           (char          上报key)
 * \param *p_data           (char          char数据)
 * \param i_count       (int      个数)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *
 */
FR_STATIC int __jbossejb_short_array_report(Frreport_body_data *p_st_body_data
                               , char *p_key
                               , Frbyte_Packet *p_st_data
                               , int i_count)
{
    char *p_json = NULL;
    char arr_tmp[4];
    uint16_t u16_value = 0;
    int i_buff_size = NULL;
    int i_used_size = 0;
    int i_tmp = 0;
    int i = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || p_key == NULL)
        return FR_FAIL;

    i_buff_size = 5 * i_count + 1;
    p_json = (char *)frmalloc(i_buff_size);
    if (p_json == NULL)
        return FR_FAIL;
    memset(p_json, 0x00, i_buff_size);

    strcpy(p_json, "[");
    i_used_size = 1;

    for (; i < i_count; i++)
    {
        if (bytebuff_get_short(p_st_data, 2, &u16_value, BYTE_BIG_ENDIAN) == FR_FAIL)
        {
            frfree(p_json);
            return FR_FAIL;
        }

        memset(arr_tmp, 0x00, sizeof(arr_tmp));
        snprintf(arr_tmp, sizeof(arr_tmp), "%d", u16_value);
        i_tmp = strlen(arr_tmp);

        if (i == i_count - 1)
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s", arr_tmp);
            i_used_size += i_tmp;
        }
        else
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s,", arr_tmp);
            i_used_size += (i_tmp+1);
        }
    }
    snprintf(p_json+i_used_size, i_buff_size - i_used_size, "]");

    // json格式上报
    if (frreport_body_l7_add_str(p_st_body_data, p_key, p_json) == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * int数组上报
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_key           (char          上报key)
 * \param *p_data           (char          char数据)
 * \param i_count       (int      个数)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *
 */
FR_STATIC int __jbossejb_int_array_report(Frreport_body_data *p_st_body_data
                               , char *p_key
                               , Frbyte_Packet *p_st_data
                               , int i_count)
{
    char *p_json = NULL;
    char arr_tmp[11];
    uint32_t u32_value = 0;
    int i_buff_size = NULL;
    int i_used_size = 0;
    int i_tmp = 0;
    int i = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || p_key == NULL)
        return FR_FAIL;

    i_buff_size = 12 * i_count + 1;
    p_json = (char *)frmalloc(i_buff_size);
    if (p_json == NULL)
        return FR_FAIL;
    memset(p_json, 0x00, i_buff_size);

    strcpy(p_json, "[");
    i_used_size = 1;

    for (; i < i_count; i++)
    {
        if (bytebuff_get_int(p_st_data, 4, &u32_value, BYTE_BIG_ENDIAN) == FR_FAIL)
        {
            frfree(p_json);
            return FR_FAIL;
        }

        memset(arr_tmp, 0x00, sizeof(arr_tmp));
        snprintf(arr_tmp, sizeof(arr_tmp), "%d", u32_value);
        i_tmp = strlen(arr_tmp);

        if (i == i_count - 1)
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s", arr_tmp);
            i_used_size += i_tmp;
        }
        else
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s,", arr_tmp);
            i_used_size += (i_tmp+1);
        }
    }
    snprintf(p_json+i_used_size, i_buff_size - i_used_size, "]");

    // json格式上报
    if (frreport_body_l7_add_str(p_st_body_data, p_key, p_json) == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * long数组上报
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_key           (char          上报key)
 * \param *p_data           (char          char数据)
 * \param i_count       (int      个数)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *
 */
FR_STATIC int __jbossejb_long_array_report(Frreport_body_data *p_st_body_data
                               , char *p_key
                               , Frbyte_Packet *p_st_data
                               , int i_count)
{
    char *p_json = NULL;
    char arr_tmp[11];
    uint64_t u64_value = 0;
    int i_buff_size = NULL;
    int i_used_size = 0;
    int i_tmp = 0;
    int i = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || p_key == NULL)
        return FR_FAIL;

    i_buff_size = 12 * i_count + 1;
    p_json = (char *)frmalloc(i_buff_size);
    if (p_json == NULL)
        return FR_FAIL;
    memset(p_json, 0x00, i_buff_size);

    strcpy(p_json, "[");
    i_used_size = 1;

    for (; i < i_count; i++)
    {
        if (bytebuff_get_long(p_st_data, 8, &u64_value, BYTE_BIG_ENDIAN) == FR_FAIL)
        {
            frfree(p_json);
            return FR_FAIL;
        }

        memset(arr_tmp, 0x00, sizeof(arr_tmp));
        snprintf(arr_tmp, sizeof(arr_tmp), "%d", u64_value);
        i_tmp = strlen(arr_tmp);

        if (i == i_count - 1)
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s", arr_tmp);
            i_used_size += i_tmp;
        }
        else
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s,", arr_tmp);
            i_used_size += (i_tmp+1);
        }
    }
    snprintf(p_json+i_used_size, i_buff_size - i_used_size, "]");

    // json格式上报
    if (frreport_body_l7_add_str(p_st_body_data, p_key, p_json) == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * float数组上报
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_key           (char          上报key)
 * \param *p_data           (char          char数据)
 * \param i_count       (int      个数)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *
 */
FR_STATIC int __jbossejb_float_array_report(Frreport_body_data *p_st_body_data
                               , char *p_key
                               , Frbyte_Packet *p_st_data
                               , int i_count)
{
    char *p_json = NULL;
    char arr_tmp[64];
    uint32_t u32_value = 0;
    int i_buff_size = NULL;
    int i_used_size = 0;
    int i_tmp = 0;
    union int32_float_bits u_32bits;
    float f_value = 0.0;
    int i = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || p_key == NULL)
        return FR_FAIL;

    i_buff_size = 32 * i_count + 1;
    p_json = (char *)frmalloc(i_buff_size);
    if (p_json == NULL)
        return FR_FAIL;
    memset(p_json, 0x00, i_buff_size);

    strcpy(p_json, "[");
    i_used_size = 1;

    for (; i < i_count; i++)
    {
        if (bytebuff_get_int(p_st_data, 4, &u32_value, BYTE_BIG_ENDIAN) == FR_FAIL)
        {
            frfree(p_json);
            return FR_FAIL;
        }

        u_32bits.int_bits = u32_value;
        f_value = u_32bits.float_bits;

        memset(arr_tmp, 0x00, sizeof(arr_tmp));
        snprintf(arr_tmp, sizeof(arr_tmp), "%d", f_value);
        i_tmp = strlen(arr_tmp);

        if (i == i_count - 1)
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s", arr_tmp);
            i_used_size += i_tmp;
        }
        else
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s,", arr_tmp);
            i_used_size += (i_tmp+1);
        }
    }
    snprintf(p_json+i_used_size, i_buff_size - i_used_size, "]");

    // json格式上报
    if (frreport_body_l7_add_str(p_st_body_data, p_key, p_json) == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * double数组上报
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_key           (char          上报key)
 * \param *p_data           (char          char数据)
 * \param i_count       (int      个数)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *
 */
FR_STATIC int __jbossejb_double_array_report(Frreport_body_data *p_st_body_data
                               , char *p_key
                               , Frbyte_Packet *p_st_data
                               , int i_count)
{
    char *p_json = NULL;
    char arr_tmp[64];
    uint64_t u64_value = 0;
    int i_buff_size = NULL;
    int i_used_size = 0;
    int i_tmp = 0;
    union int64_double_bits u_64bits;
    double db_value = 0.0;
    int i = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || p_key == NULL)
        return FR_FAIL;

    i_buff_size = 32 * i_count + 1;
    p_json = (char *)frmalloc(i_buff_size);
    if (p_json == NULL)
        return FR_FAIL;
    memset(p_json, 0x00, i_buff_size);

    strcpy(p_json, "[");
    i_used_size = 1;

    for (; i < i_count; i++)
    {
        if (bytebuff_get_long(p_st_data, 8, &u64_value, BYTE_BIG_ENDIAN) == FR_FAIL)
        {
            frfree(p_json);
            return FR_FAIL;
        }

        u_64bits.int_bits = u64_value;
        db_value = u_64bits.double_bits;

        memset(arr_tmp, 0x00, sizeof(arr_tmp));
        snprintf(arr_tmp, sizeof(arr_tmp), "%d", db_value);
        i_tmp = strlen(arr_tmp);

        if (i == i_count - 1)
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s", arr_tmp);
            i_used_size += i_tmp;
        }
        else
        {
            snprintf(p_json+i_used_size, i_buff_size - i_used_size, "%s,", arr_tmp);
            i_used_size += (i_tmp+1);
        }
    }
    snprintf(p_json+i_used_size, i_buff_size - i_used_size, "]");

    // json格式上报
    if (frreport_body_l7_add_str(p_st_body_data, p_key, p_json) == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * boolean数组上报
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_key           (char          上报key)
 * \param *p_data           (char          char数据)
 * \param i_count       (int      个数)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *
 */
FR_STATIC int __jbossejb_boolean_array_report(Frreport_body_data *p_st_body_data
                               , char *p_key
                               , char *p_data
                               , int i_count)
{
    char *p_json = NULL;
    char arr_tmp[64];
    uint64_t u64_value = 0;
    int i_buff_size = NULL;
    int i_used_size = 0;
    int i_left_size = 0;
    int i_tmp = 0;
    int i = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || p_key == NULL)
        return FR_FAIL;

    i_buff_size = 3 * i_count + 1;
    p_json = (char *)frmalloc(i_buff_size);
    if (p_json == NULL)
        return FR_FAIL;
    memset(p_json, 0x00, i_buff_size);

    strcpy(p_json, "[");
    i_used_size = 1;

    i_left_size = i_buff_size - i_used_size;
    for (; i < i_count; i++)
    {
        if (__hex_to_boolean(p_data+i, p_json, &i_left_size) == FR_FAIL)
        {
            frfree(p_json);
            return FR_FAIL;
        }
    }
    p_json[strlen(p_json)-1] = ']';

    // json格式上报
    if (frreport_body_l7_add_str(p_st_body_data, p_key, p_json) == FR_FAIL)
    {
        frfree(p_json);
        return FR_FAIL;
    }
    frfree(p_json);

    return FR_SUCC;
}

/*!
 * char数组解析
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_st_data           (Frbyte_Packet          数据)
 * \param i_count       (int      个数)
 * \param *p_key           (char          上报key)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *         APM_L7_ANALYZE_TODO:数据包不完整
 *
 */
int jbossejb_arg_char_array(Frreport_body_data *p_st_body_data
                         , Frbyte_Packet *p_st_data
                         , int i_count
                         , char *p_key)
{
    char *p_char = NULL;
    char *p_iconv_outbuf = NULL;
    unsigned int ui_iconv_outlen = 0;
    uint8_t u8_value = 0;
    int i = 0;
    int i_ret = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || i_count == 0 || p_key == NULL)
        return FR_FAIL;

    if (bytebuff_get_char(p_st_data, &u8_value) == FR_FAIL)
        return FR_FAIL;

    // 25
    if (u8_value != CHAR_TYPE)
        return FR_FAIL;

    if (bytebuff_remaining(p_st_data) < 2*i_count)
        return APM_L7_ANALYZE_TODO;

    p_char = (char *)frmalloc(i_count*2 + 1);
    if (p_char == NULL)
        return FR_FAIL;

    if (bytebuff_get_bytes(p_st_data, p_char, i_count*2) == FR_FAIL)
        goto err;
    p_char[i_count*2] = '\0';

    i_ret = iconv_to_utf8(p_char, i_count*2, (char *)"UNICODE"
                            , &p_iconv_outbuf, &ui_iconv_outlen);
    if (i_ret != 0)
        goto err;

    frfree(p_char);
    p_char = NULL;

    i_ret = __jbossejb_char_array_report(p_st_body_data, p_key, p_iconv_outbuf, i_count);
    if (i_ret == FR_FAIL)
        goto err;

    frfree(p_iconv_outbuf);
    return FR_SUCC;

err:
    if (p_char)
        frfree(p_char);

    if (p_iconv_outbuf)
        frfree(p_iconv_outbuf);

    return FR_FAIL;
}

/*!
 * short数组解析
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_st_data           (Frbyte_Packet          数据)
 * \param i_count       (int      个数)
 * \param *p_key           (char          上报key)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *         APM_L7_ANALYZE_TODO:数据包不完整
 *
 */
int jbossejb_arg_short_array(Frreport_body_data *p_st_body_data
                         , Frbyte_Packet *p_st_data
                         , int i_count
                         , char *p_key)
{
    char *p_char = NULL;
    char *p_iconv_outbuf = NULL;
    unsigned int ui_iconv_outlen = 0;
    uint8_t u8_value = 0;
    int i = 0;
    int i_ret = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || i_count == 0 || p_key == NULL)
        return FR_FAIL;

    // 22
    if (u8_value != SHORT_TYPE)
        return FR_FAIL;

    if (bytebuff_remaining(p_st_data) < 2*i_count)
        return APM_L7_ANALYZE_TODO;

    i_ret = __jbossejb_short_array_report(p_st_body_data, p_key, p_st_data, i_count);
    if (i_ret == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * int数组解析
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_st_data           (Frbyte_Packet          数据)
 * \param i_count       (int      个数)
 * \param *p_key           (char          上报key)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *         APM_L7_ANALYZE_TODO:数据包不完整
 *
 */
int jbossejb_arg_int_array(Frreport_body_data *p_st_body_data
                         , Frbyte_Packet *p_st_data
                         , int i_count
                         , char *p_key)
{
    char *p_char = NULL;
    char *p_iconv_outbuf = NULL;
    unsigned int ui_iconv_outlen = 0;
    uint8_t u8_value = 0;
    int i = 0;
    int i_ret = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || i_count == 0 || p_key == NULL)
        return FR_FAIL;

    // 23
    if (u8_value != INT_TYPE)
        return FR_FAIL;

    if (bytebuff_remaining(p_st_data) < 4*i_count)
        return APM_L7_ANALYZE_TODO;

    i_ret = __jbossejb_int_array_report(p_st_body_data, p_key, p_st_data, i_count);
    if (i_ret == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * long数组解析
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_st_data           (Frbyte_Packet          数据)
 * \param i_count       (int      个数)
 * \param *p_key           (char          上报key)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *         APM_L7_ANALYZE_TODO:数据包不完整
 *
 */
int jbossejb_arg_long_array(Frreport_body_data *p_st_body_data
                         , Frbyte_Packet *p_st_data
                         , int i_count
                         , char *p_key)
{
    char *p_char = NULL;
    char *p_iconv_outbuf = NULL;
    unsigned int ui_iconv_outlen = 0;
    uint8_t u8_value = 0;
    int i = 0;
    int i_ret = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || i_count == 0 || p_key == NULL)
        return FR_FAIL;

    // 24
    if (u8_value != LONG_TYPE)
        return FR_FAIL;

    if (bytebuff_remaining(p_st_data) < 8*i_count)
        return APM_L7_ANALYZE_TODO;

    i_ret = __jbossejb_long_array_report(p_st_body_data, p_key, p_st_data, i_count);
    if (i_ret == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * float数组解析
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_st_data           (Frbyte_Packet          数据)
 * \param i_count       (int      个数)
 * \param *p_key           (char          上报key)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *         APM_L7_ANALYZE_TODO:数据包不完整
 *
 */
int jbossejb_arg_float_array(Frreport_body_data *p_st_body_data
                         , Frbyte_Packet *p_st_data
                         , int i_count
                         , char *p_key)
{
    char *p_char = NULL;
    char *p_iconv_outbuf = NULL;
    unsigned int ui_iconv_outlen = 0;
    uint8_t u8_value = 0;
    int i = 0;
    int i_ret = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || i_count == 0 || p_key == NULL)
        return FR_FAIL;

    // 26
    if (u8_value != FLOAT_TYPE)
        return FR_FAIL;

    if (bytebuff_remaining(p_st_data) < 4*i_count)
        return APM_L7_ANALYZE_TODO;

    i_ret = __jbossejb_float_array_report(p_st_body_data, p_key, p_st_data, i_count);
    if (i_ret == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * double数组解析
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_st_data           (Frbyte_Packet          数据)
 * \param i_count       (int      个数)
 * \param *p_key           (char          上报key)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *         APM_L7_ANALYZE_TODO:数据包不完整
 *
 */
int jbossejb_arg_double_array(Frreport_body_data *p_st_body_data
                         , Frbyte_Packet *p_st_data
                         , int i_count
                         , char *p_key)
{
    char *p_char = NULL;
    char *p_iconv_outbuf = NULL;
    unsigned int ui_iconv_outlen = 0;
    uint8_t u8_value = 0;
    int i = 0;
    int i_ret = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || i_count == 0 || p_key == NULL)
        return FR_FAIL;

    // 27
    if (u8_value != DOUBLE_TYPE)
        return FR_FAIL;

    if (bytebuff_remaining(p_st_data) < 4*i_count)
        return APM_L7_ANALYZE_TODO;

    i_ret = __jbossejb_double_array_report(p_st_body_data, p_key, p_st_data, i_count);
    if (i_ret == FR_FAIL)
        return FR_FAIL;

    return FR_SUCC;
}

/*!
 * boolean数组解析
 *
 * \param *p_st_body_data      (Frreport_body_data    上报数据)
 * \param *p_st_data           (Frbyte_Packet          数据)
 * \param i_count       (int      个数)
 * \param *p_key           (char          上报key)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败\n
 *         APM_L7_ANALYZE_TODO:数据包不完整
 *
 */
int jbossejb_arg_boolean_array(Frreport_body_data *p_st_body_data
                         , Frbyte_Packet *p_st_data
                         , int i_count
                         , char *p_key)
{
    char *p_boolean = NULL;
    uint8_t u8_value = 0;
    int i_hex_count = 0;
    int i = 0;
    int i_ret = 0;

    if (p_st_body_data == NULL || p_st_data == NULL || i_count == 0 || p_key == NULL)
        return FR_FAIL;

    // 20
    if (u8_value != BOOLEAN_TYPE)
        return FR_FAIL;

    if ((i_count%8) == 0)
        i_hex_count = i_count/8;
    else
        i_hex_count = i_count/8 + 1;

    p_boolean = __get_string_reverse(p_st_data, i_hex_count);
    if (p_boolean == NULL)
        return FR_FAIL;

    i_ret = __jbossejb_boolean_array_report(p_st_body_data, p_key, p_boolean, i_hex_count);
    if (i_ret == FR_FAIL)
    {
        frfree(p_boolean);
        return FR_FAIL;
    }

    frfree(p_boolean);
    return FR_SUCC;
}
